function Install-Insight {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)][Parameters]$Parameters
    )

    Write-Host # Newline.
    Write-host "Installing LS Insight..."

    # Do necessary install preperations.
    Start-InstallPreperation -Parameters $Parameters

    # LS Insight SQL server.
    $params = @{
        Server = $Parameters.LSInsight.Server
        Location = $Parameters.LSInsight.Location
        ResourceGroup = $Parameters.Azure.ResourceGroup
        ClientIPAddress = $Parameters.LSInsight.ClientIPAddress
        Placement = $Parameters.LSInsight.Placement
    }
    $NewServer = Set-InsightServer @params
    if ($NewServer) {
        $Parameters.LSInsight.Server.FullyQualifiedDomainName = $NewServer.FullyQualifiedDomainName
    }

    # LS Insight SQL database.
    $params = @{
        Server = $Parameters.LSInsight.Server
        Database = $Parameters.LSInsight.Database
        ResourceGroup = $Parameters.Azure.ResourceGroup
        Location = $Parameters.LSInsight.Location
        Placement = $Parameters.LSInsight.Placement
    }
    Set-InsightDatabase @params

    # LS Insight Azure Data Factory v2.
    Set-InsightADFv2 -Parameters $Parameters

    # Insert the company names into the LS Insight database.
    $companyParams = @{
        ServerName = $Parameters.LSInsight.Server.FullyQualifiedDomainName
        Credential = $Parameters.LSInsight.Server.Credential
        DatabaseName = $Parameters.LSInsight.Database.Name
        Companies = $Parameters.LSCentral.Companies
    }
    Set-Company @companyParams

    
    # Add pre-staging tables. (For SaaS).
    if ($Parameters.LSCentral.Placement -eq 'SaaS_In_Cloud') {
        Add-PreStagingTables -LSInsight $Parameters.LSInsight
        
        # Insert the company names into the LS Insight database.
        Set-Company @companyParams -LSC
    }

    
    # Store 'Parameters' object in the project folder.
    if ($Parameters.LSInsight.ParametersOutFilePath) {
        Write-LSParameters -Parameters $Parameters -File $Parameters.LSInsight.ParametersOutFilePath
    }

    Show-InsightParameters -LSInsight $Parameters.LSInsight  

    Write-Host "Done! - and may I say - YOU LOOK AWESOME TODAY!"
    Write-Host # Newline.

    <#
    .SYNOPSIS
        Deploys LS Insight.
    .DESCRIPTION
        The Install-Insight function deploys an instance of LS Insight.
        
        The function sets up the necessary Azure resources for LS Insight.

        A typical LS Insight deployment consists of these Azure resources:
        - Azure SQL server.
        - Azure SQL database.
        - Azure Data Factory v2.
    .EXAMPLE
        PS C:\> Install-Insight -Parameters $Params

        Deploys LS Insight.
    .INPUTS
        None. You cannot pipe objects to Install-Insight.
    .OUTPUTS
        None.
    .PARAMETER Parameters
        A 'Parameters' type object that describes the deployment process.
        A recipe for the LS Insight instance.
        Required?                    true
        Position?                    
        Default value                
        Accept pipeline input?       false
        Accept wildcard characters?  false
    .NOTES
        Even though there are no direct outputs from this function, some things are created.
        If the deployment process is successful, then the 'Parameters' object used to define the deployment is stored in the project folder.
        Depending on the deployment, some files might have been added to the project folder that were used during the deployment.
    #>
}